package com;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DBManipulation;

/**
 * Servlet implementation class CustomerMasterServlet
 */
public class CustomerMasterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CustomerMasterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		// TODO Auto-generated method stub
				
		System.out.println("In Customer Master servlet");
		
		CustomerMasterBean cBean=new CustomerMasterBean();
		
		cBean.setCustomerName(request.getParameter("customername"));
		cBean.setCustomerCode(request.getParameter("customercode"));
		cBean.setCustomerAddress(request.getParameter("customeraddress"));
		cBean.setCustomerCity(request.getParameter("city"));
		cBean.setCustomerState(request.getParameter("state"));
		cBean.setCustomerTIN(request.getParameter("customertin"));
		cBean.setCustomerPAN(request.getParameter("customerpan"));
		cBean.setCustomerMob(request.getParameter("customermobile"));
		cBean.setCustomerEmail(request.getParameter("customeremail"));
		cBean.setCustomerPerson(request.getParameter("customercontactperson"));
		cBean.setCustomerBalance(Double.parseDouble(request.getParameter("copeningbalance")));
		//cBean.setCustomerBalance(request.getParameter("copeningbalance"));

		//cBean=DBManipulation.insertCustomer(cBean);
		
		DBManipulation dbc= new DBManipulation();
		dbc.insertCustomer(cBean);
		
//		String value1=request.getParameter("jspname");
		
/*		if(value1.equals("SalesVoucher"))
		{		
			String v1=request.getParameter("ordnum");
			
			request.setAttribute("s1", v1);
			RequestDispatcher requestDispatcher;
			requestDispatcher = request.getRequestDispatcher("SalesVoucher2.jsp" ) ;
	        requestDispatcher.forward(request,response);
	        
		}
*/
//		String v1=request.getParameter("ordnum");
//		request.setAttribute("s1", v1);
//		request.getRequestDispatcher(request.getParameter("jspname")).forward(request, response);
		
/*		String value1=request.getParameter("jspname");
		
		
		if(value1.equals("SalesVoucher"))
		{
			RequestDispatcher requestDispatcher; 
	        requestDispatcher = request.getRequestDispatcher("SalesVoucher2.jsp" ) ;
	        requestDispatcher.forward(request,response);
		}
*/
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		// TODO Auto-generated method stub

	}

}
